package com.yanqu.road.server.manger.cricket;

import com.yanqu.road.entity.cricket.helper.AddHpResult;
import com.yanqu.road.entity.enums.eSkillType;
import com.yanqu.road.pb.cricket.CricketProto;
import com.yanqu.road.server.gameplayer.module.cricket.battle.CricketGame;
import com.yanqu.road.server.gameplayer.module.cricket.model.BattleData;
import com.yanqu.road.server.gameplayer.module.cricket.model.SkillData;
import com.yanqu.road.server.manger.cricket.skillhandler.attround.CricketSkillAttRoundStrategy;
import com.yanqu.road.server.manger.cricket.skillhandler.attround.handler.*;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class CricketAttRoundSkillMgr {

    /**
     * 攻击后，我方技能
     */
    private static Map<Integer, CricketSkillAttRoundStrategy> attRoundActionSkillMap = new LinkedHashMap<>();
    static {
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill163.getValue(), new CricketSkill163Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill164.getValue(), new CricketSkill164Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill147.getValue(), new CricketSkill147Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill154.getValue(), new CricketSkill154Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill149.getValue(), new CricketSkill149Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill157.getValue(), new CricketSkill157Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill168.getValue(), new CricketSkill168Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill252.getValue(), new CricketSkill252Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill254.getValue(), new CricketSkill254Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill256.getValue(), new CricketSkill256Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill257.getValue(), new CricketSkill257Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill258.getValue(), new CricketSkill258Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill403.getValue(), new CricketSkill403Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill402.getValue(), new CricketSkill402Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill404.getValue(), new CricketSkill404Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill400.getValue(), new CricketSkill400Strategy());
        attRoundActionSkillMap.put(eSkillType.CricketBattleSkill406.getValue(), new CricketSkill406Strategy());
    }
    /**
     * 攻击后，对方技能
     */
    private static Map<Integer, CricketSkillAttRoundStrategy> attRoundTargetSkillMap = new LinkedHashMap<>();
    static {
        attRoundTargetSkillMap.put(eSkillType.CricketBattleSkill146.getValue(), new CricketSkill146Strategy());
        attRoundTargetSkillMap.put(eSkillType.CricketBattleSkill155.getValue(), new CricketSkill155Strategy());
        attRoundTargetSkillMap.put(eSkillType.CricketBattleSkill158.getValue(), new CricketSkill158Strategy());
        attRoundTargetSkillMap.put(eSkillType.CricketBattleSkill166.getValue(), new CricketSkill166Strategy());
        attRoundTargetSkillMap.put(eSkillType.CricketBattleSkill407.getValue(), new CricketSkill407Strategy());

    }

    /**
     * 攻击后，我方技能
     * @param cricketGame 本局对局对象
     * @param skillData 触发的技能
     * @param baseAttSkill 基础攻击技能
     * @param baseAttReHpResult 基础攻击结果对象
     * @param action 我方
     * @param target 对方
     * @param attackRoundBuilder 返回PB结构体
     * @param battleFrameId 本次攻击的FrameId
     * @return true：死亡，退出技能处理，false：继续技能处理
     */
    public static boolean actionSkillHandle(CricketGame cricketGame, SkillData skillData, SkillData baseAttSkill, AddHpResult baseAttReHpResult, BattleData action, BattleData target, CricketProto.CricketAttackRound.Builder attackRoundBuilder, long battleFrameId) {
        CricketSkillAttRoundStrategy cricketSkillAttRoundStrategy = attRoundActionSkillMap.get(skillData.getSkillEffect().getSkillType());
        if (cricketSkillAttRoundStrategy != null) {
            return cricketSkillAttRoundStrategy.skillHandle(cricketGame, skillData, baseAttSkill, baseAttReHpResult, action, target, attackRoundBuilder, battleFrameId);
        }
        return false;
    }

    /**
     * 攻击后，对方技能
     * @param cricketGame 本局对局对象
     * @param skillData 触发的技能
     * @param baseAttSkill 基础攻击技能
     * @param baseAttReHpResult 基础攻击结果对象
     * @param action 我方
     * @param target 对方
     * @param attackRoundBuilder 返回PB结构体
     * @param battleFrameId 本次攻击的FrameId
     * @return true：死亡，退出技能处理，false：继续技能处理
     */
    public static boolean targetSkillHandle(CricketGame cricketGame, SkillData skillData, SkillData baseAttSkill, AddHpResult baseAttReHpResult, BattleData action, BattleData target, CricketProto.CricketAttackRound.Builder attackRoundBuilder, long battleFrameId) {
        CricketSkillAttRoundStrategy cricketSkillAttRoundStrategy = attRoundTargetSkillMap.get(skillData.getSkillEffect().getSkillType());
        if (cricketSkillAttRoundStrategy != null) {
            return cricketSkillAttRoundStrategy.skillHandle(cricketGame, skillData, baseAttSkill, baseAttReHpResult, action, target, attackRoundBuilder, battleFrameId);
        }
        return false;
    }
}
